package com.kim.store.contorller;

import com.kim.store.entity.Product;
import com.kim.store.service.IProductService;
import com.kim.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/product")
public class ProductController extends BaseController{
    @Autowired
    private IProductService productService;

    @RequestMapping("/hot_list")
    public JsonResult<List<Product>> findHotList(){
        List<Product> data = productService.findHotList();
        return new JsonResult<>(OK,data);
    }

    @RequestMapping("/detail/{id}")
    public JsonResult<Product> findById(@PathVariable("id") Integer id){
        Product data = productService.findById(id);
        return new JsonResult<>(OK,data);
    }
}
